<?php
/**
 * ClassName: ProfitShareService
 * Description: 微信商户分账配置
 * @Author 周昌
 * @Create 2023/11/8 14:00
 */

namespace service\admin;


use epii\admin\center\config\Settings;
use epii\cache\Cache;
use libs\Tool;
use service\BaseService;

class ProfitShareService extends BaseService
{
    protected static $model='model\ProfitShareModel';
    public function __construct()
    {
        parent::__construct();
    }
    /**
     * #User: Administrator
     * #Time: 2024/2/1 9:44
     * #Author:周昌
     * #Description:根据条件 计算分账比例
     * @param $amount float|string 需要添加/修改的商户号分账比例
     * @param array $where 查询条件
     * @return array
     */
//    public static function shareRatio($amount,$where=[])
//    {
//        $where[]=['status','=',self::$status_index['yes']];
////        $where[]=['hospital_group_id','=',self::getUserHospitalGroupId()];//医院组
//        $total_amount=self::$model::getSum($where,'amount');
//        $total_amount=bcadd($total_amount,$amount,2);
//        $profit_ratio=self::getRatio();
//        if($total_amount>self::$profit_ratio){
//            return Tool::Error('分账比例总和不能超过'.$profit_ratio);
//        }
//        return Tool::Success();
//    }
//    //获取分账总比例
//    public static function getRatio()
//    {
//        return Settings::get('profit_ratio');
//    }
    //列表数据
    public static function getAjaxData($where)
    {
        $table = self::$model::order('id desc');
        return self::tableJsonData($table, $where, function ($data){
            $data['hospital_group_name']=HospitalService::getNameByKey($data['hospital_group_id']);
            return $data;
        });
    }

}